//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
#include "CalcObj.h"
#include "uCalcExcel.h"
#include "uCalcOO.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//---------------------------------------------------------------------------
CCalc *__fastcall CreateCalcObject( bool bDisplayErr /* = true */)
{
  Variant vOleObj;

  ::CoInitialize( NULL);

  try {
    vOleObj = Variant::CreateObject( "Excel.Application");
    vOleObj.OleFunction( "Quit");
    return new CExcel();
  } catch( Exception &e) {
  }

  try {
    Variant vOO = CreateOleObject( "com.sun.star.ServiceManager");
    vOleObj = vOO.OleFunction( "createInstance", "com.sun.star.frame.Desktop");
    vOleObj.OleFunction( "terminate");
    return new COOCalc();
  } catch( Exception &e) {
  }

  if( bDisplayErr) EICErreur( "Vous ne pouvez pas utiliser cette fonctionnalité car Excel ou OpenOffice n'est pas installé sur votre poste !");
  return NULL;
}
//---------------------------------------------------------------------------
